import Image,ImageDraw
import ImageOps
from random import randint as rint

def randgradient():
	img  = Image.new("RGBA", (358,138), "#123")
	draw = ImageDraw.Draw(img)

	img2  = Image.new("RGBA", (358,20), "#000")
	draw2 = ImageDraw.Draw(img2)

	# Fundo
	im = Image.open("bg.png")
	size = 2*358, 2*138
	size_trophy = 20,20
	#im.thumbnail(size,Image.ANTIALIAS)
	im = ImageOps.fit(im, (358,138), method=Image.ANTIALIAS, centering=(0.5, 0.5))
	img.paste(im, (0, 0))

	# Trofeus
	im_plat   = Image.open("platinum.png")
	im_plat.thumbnail(size_trophy,Image.ANTIALIAS)
	im_gold   = Image.open("gold.png")
	im_gold.thumbnail(size_trophy,Image.ANTIALIAS)
	im_silver = Image.open("silver.png")
	im_silver.thumbnail(size_trophy,Image.ANTIALIAS)
	im_bronze = Image.open("bronze.png")
	im_bronze.thumbnail(size_trophy,Image.ANTIALIAS)

	draw2.rectangle((0, 0, 358, 120)   , fill=(0,0,0,180))
	img.paste(img2, (0, 0), img2)
	img.paste(img2, (0, 125), img2)

	#draw2.rectangle([(0, 125), (358, 138)], fill=(0,0,0,80))

	img.paste(im_plat  , (310, 2) , im_plat)
	img.paste(im_gold  , (310, 24), im_gold)
	img.paste(im_silver, (310, 46), im_silver)
	img.paste(im_bronze, (310, 68), im_bronze)

	img.save("out.png", "PNG")

if __name__ == "__main__":
	randgradient()
